package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.RemoteManagerService;
import com.ruoyi.system.api.RemoteUserService;
import com.ruoyi.system.api.domain.Content;
import com.ruoyi.system.api.domain.Item;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.api.model.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteManagerFallbackFactory implements FallbackFactory<RemoteManagerService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteManagerFallbackFactory.class);

    @Override
    public RemoteManagerService create(Throwable throwable)
    {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new RemoteManagerService() {

            @Override
            public R<List<Content>> findContentsByCateId(Long cateId) {
                return R.fail("查询某个广告分类列表失败:" + throwable.getMessage());
            }

            @Override
            public R<Content> findById(Long id) {
                return R.fail("查询广告失败:" + throwable.getMessage());
            }

            @Override
            public R<List<Item>> findAll() {
                return R.fail("查询sku商品列表失败:" + throwable.getMessage());
            }

            @Override
            public R<Item> findItemById(Long id) {
                return R.fail("查询sku商品失败:" + throwable.getMessage());
            }
        };
    }
}
